<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('添加药品')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: summernote-css"/>
    <th:block th:include="include :: jquery-smartwizard-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
    <th:block th:include="include :: summernote-css"/>

</head>
<script src="../static/js/xm-select.js" th:src="@{/js/xm-select.js}"></script>

<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-drug-add">
        <ul class="nav nav-tabs">
            <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true"> 基本信息</a>
            </li>
            <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">商品相册</a>
            </li>
            <li class=""><a data-toggle="tab" href="#tab-3" aria-expanded="false">药品百科</a>
            </li>
            <li class=""><a data-toggle="tab" href="#tab-4" aria-expanded="false">药品TDK</a>
            </li>
            <li class=""><a data-toggle="tab" href="#tab-5" aria-expanded="false">药品资讯TDK</a>
            </li>
            <li class=""><a data-toggle="tab" href="#tab-6" aria-expanded="false">药品问答TDK</a>
            </li>
            <li class=""><a data-toggle="tab" href="#tab-7" aria-expanded="false">公开资料参考价格TDK</a>
            </li>
        </ul>
        <div class="tab-content">
            <div id="tab-1" class="tab-pane active" style="padding: 20px">
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">各版本药物价格</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="editionPrice" name="editionPrice" type="text/plain"></script>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label ">中国是否上市</label>
                        <div class="col-sm-10">
                            <label class="radio-box"> <input type="radio" name="chinaListedState" value="0"/> 否
                            </label>
                            <label class="radio-box"> <input type="radio" name="chinaListedState" value="1"/> 是
                            </label>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">是否进入医保</label>
                        <div class="col-sm-10">
                            <label class="radio-box"> <input type="radio" name="enterMedicalState" value="0"/> 否
                            </label>
                            <label class="radio-box"> <input type="radio" name="enterMedicalState" value="1"/> 是
                            </label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label ">是否有仿制药</label>
                        <div class="col-sm-10">
                            <label class="radio-box"> <input type="radio" name="genericState" value="0"/> 否 </label>
                            <label class="radio-box"> <input type="radio" name="genericState" value="1"/> 是 </label>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">国内是否能买到</label>
                        <div class="col-sm-10">
                            <label class="radio-box"> <input type="radio" name="canChinaState" value="0"/> 否 </label>
                            <label class="radio-box"> <input type="radio" name="canChinaState" value="1"/> 是 </label>
                        </div>
                    </div>
                </div>

                <div class="form-group row">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">选择疾病</label>
                        <div class="col-sm-10">
                            <div id="selectDemo"></div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">厂家</label>
                        <div class="col-sm-10">
                            <div id="selectFactory"></div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">准批文号</label>
                        <div class="col-sm-10">
                            <input name="quasiApprovalNo" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">是否处方药</label>
                        <div class="col-sm-10">
                            <label class="radio-box"> <input type="radio" name="isPrescription" value="0"/> 否 </label>
                            <label class="radio-box"> <input type="radio" name="isPrescription" value="1"/> 是 </label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">主图</label>
                        <div class="col-sm-11">
                            <input type="hidden" name="icon">
                            <div class="file-loading">
                                <input class="form-control file-upload" id="icon" name="file" type="file">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">权重</label>
                        <div class="col-sm-10">
                            <input name="salesvolume" class="form-control" type="text">
                        </div>
                    </div>
<!--                    <div class="col-sm-6">-->
<!--                        <label class="col-sm-2 control-label">适用人群</label>-->
<!--                        <div class="col-sm-10">-->
<!--                            <input name="suitableforthecroud" class="form-control">-->
<!--                        </div>-->
<!--                    </div>-->
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">用法用量</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="usageanddosage" name="usageanddosage" type="text/plain"></script>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">副作用</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="untoward" name="untoward" type="text/plain"></script>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">注意事项</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="announcements" name="announcements" type="text/plain"></script>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">价格与购买</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="adaptationdisease" name="adaptationdisease" type="text/plain"></script>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">药物相互作用</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="mutual" name="mutual" type="text/plain"></script>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">治疗效果</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="therapeuticEffect" name="therapeuticEffect" type="text/plain"></script>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">温馨提示</label>
                        <div class="col-sm-11">
                            <textarea name="warmPrompt" class="form-control"></textarea>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">参考资料</label>
                        <div class="col-sm-11">
                            <textarea name="referenceMaterial" class="form-control"></textarea>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">信息来源</label>
                        <div class="col-sm-11">
                            <textarea name="informationSources" class="form-control"></textarea>
                        </div>
                    </div>
                </div>


            </div>
            <div id="tab-2" class="tab-pane " style="padding: 20px">
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">商品相册</label>
                        <div class="col-sm-11">
                            <input type="hidden" name="photoalbum">
                            <div class="file-loading">
                                <input class="form-control files-upload" id="photoalbum" name="files" type="file"
                                       multiple>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div id="tab-3" class="tab-pane " style="padding: 20px">
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">名称</label>
                        <div class="col-sm-10">
                            <input name="name" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">通用名称</label>
                        <div class="col-sm-10">
                            <input name="commonName" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">英文名称</label>
                        <div class="col-sm-10">
                            <input name="englishName" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">别名</label>
                        <div class="col-sm-10">
                            <input name="alias" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">适应症</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="adaptationdisease1" name="adaptationdisease1" type="text/plain"></script>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">适应靶点</label>
                        <div class="col-sm-10">
                            <input name="adaptiveTarget" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">主要成分</label>
                        <div class="col-sm-10">
                            <input name="ingredient1" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">剂型</label>
                        <div class="col-sm-11">
                            <input name="dosage" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">适应人群</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="intendedPopulation" name="intendedPopulation" type="text/plain"></script>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">包装（规格）</label>
                    <div class="col-sm-11">
                        <input name="packaging" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">性状</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="xingzhuang" name="xingzhuang" type="text/plain"></script>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">用法用量</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="usageanddosage1" name="usageanddosage1" type="text/plain"></script>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">副作用</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="untoward1" name="untoward1" type="text/plain"></script>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">注意事项</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="announcements1" name="announcements1" type="text/plain"></script>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">特殊人群购药</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="suitableforthecroud1" name="suitableforthecroud1" type="text/plain"></script>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">禁忌症</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="taboos1" name="taboos1" type="text/plain"></script>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">药物相互作用</label>
                        <div class="col-sm-11">
                            <input type="hidden" class="form-control" required>
                            <script id="mutual1" name="mutual1" type="text/plain"></script>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">贮存方法</label>
                        <div class="col-sm-10">
                            <input name="storagecondition" class="form-control" type="text">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-2 control-label">有效期</label>
                        <div class="col-sm-10">
                            <input name="periodOfValidity" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">药物过量</label>
                        <div class="col-sm-11">
                            <textarea name="overdose" class="form-control"></textarea>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <label class="col-sm-1 control-label">药代动力学</label>
                        <div class="col-sm-11">
                            <textarea name="pharmacokinetics" class="form-control"></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <div id="tab-4" class="tab-pane " style="padding: 20px">
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品标题</label>
                    <div class="col-sm-10">
                        <input name="webtitle" class="form-control" placeholder="请输入标题" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品关键词</label>
                    <div class="col-sm-10">
                        <input name="keywords" class="form-control" placeholder="请输入关键词" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品描述</label>
                    <div class="col-sm-10">
                        <input name="description" class="form-control" placeholder="请输入描述" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品说明</label>
                    <div class="col-sm-10">
                        <input name="tdkTitle" class="form-control" placeholder="请输入说明" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品内容</label>
                    <div class="col-sm-10">
                        <input type="hidden" class="form-control" required>
                        <script id="tdkDescribe" name="tdkDescribe" type="text/plain"></script>
                    </div>
                </div>
            </div>

            <div id="tab-5" class="tab-pane " style="padding: 20px">
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品资讯标题</label>
                    <div class="col-sm-10">
                        <input name="newsTitle" class="form-control" placeholder="请输入标题" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品资讯关键词</label>
                    <div class="col-sm-10">
                        <input name="newsKeywords" class="form-control" placeholder="请输入关键词" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品资讯描述</label>
                    <div class="col-sm-10">
                        <input name="newsDescription" class="form-control" placeholder="请输入描述" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品资讯说明</label>
                    <div class="col-sm-10">
                        <input name="newsIllustrate" class="form-control" placeholder="请输入说明" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品资讯内容</label>
                    <div class="col-sm-10">
                        <input type="hidden" class="form-control" required>
                        <script id="newsContent" name="newsContent" type="text/plain"></script>
                    </div>
                </div>
            </div>

            <div id="tab-6" class="tab-pane " style="padding: 20px">
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品问答标题</label>
                    <div class="col-sm-10">
                        <input name="queTitle" class="form-control" placeholder="请输入标题" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品问答关键词</label>
                    <div class="col-sm-10">
                        <input name="queKeywords" class="form-control" placeholder="请输入关键词" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品问答描述</label>
                    <div class="col-sm-10">
                        <input name="queDescription" class="form-control" placeholder="请输入描述" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品问答说明</label>
                    <div class="col-sm-10">
                        <input name="queIllustrate" class="form-control" placeholder="请输入说明" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品问答内容</label>
                    <div class="col-sm-10">
                        <input type="hidden" class="form-control" required>
                        <script id="queContent" name="queContent" type="text/plain"></script>
                    </div>
                </div>
            </div>

            <div id="tab-7" class="tab-pane " style="padding: 20px">
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品价格标题</label>
                    <div class="col-sm-10">
                        <input name="priceTitle" class="form-control" placeholder="请输入标题" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品价格关键词</label>
                    <div class="col-sm-10">
                        <input name="priceKeywords" class="form-control" placeholder="请输入关键词" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品问答描述</label>
                    <div class="col-sm-10">
                        <input name="priceDescription" class="form-control" placeholder="请输入描述" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品价格说明</label>
                    <div class="col-sm-10">
                        <input name="priceIllustrate" class="form-control" placeholder="请输入说明" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">药品价格内容</label>
                    <div class="col-sm-10">
                        <input type="hidden" class="form-control" required>
                        <script id="priceContent" name="priceContent" type="text/plain"></script>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<th:block th:include="include :: summernote-js"/>
<th:block th:include="include :: jquery-smartwizard-js"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>
<th:block th:include="include :: summernote-js"/>
<script src="/ueditor/ueditor.config.js" type="text/javascript" charSet="utf-8"></script>
<script src="/ueditor/ueditor.all.js" type="text/javascript" charSet="utf-8"></script>
<script src="/ueditor/lang/zh-cn/zh-cn.js" type="text/javascript" charSet="utf-8"></script>
<script th:inline="javascript">
    var selectData = [];
    var factoryData = [];
    var backdis = [];
    var backFactory = [];
    var disarr = [];
    var factoryArr = [];
    var prefix = ctx + "ydz/drug"
    $("#form-drug-add").validate({
        focusCleanup: true
    });

    function remove(e) {
        $(e).parent().remove();
    }

    $(document).ready(function () {
        parent.$('body').find('.layui-layer-max:not(.layui-layer-maxmin)').click()
        //加载疾病下拉
        $.ajax({
            url: "/api/common/selectNewDisease",
            type: "get",
            success: res => {
                alldis = res.data
                for (let i = 0; i < alldis.length; i++) {
                    let val = {}
                    val.name = alldis[i].name
                    val.diseaseId = alldis[i].id
                    val.pid = alldis[i].pid
                    selectData.push(val)
                }
                initXmSelect()
            }
        })
        //加载厂家下拉
        $.ajax({
            url: "/api/common/getDictByType/drug_factory",
            type: "get",
            success: res => {
                var factoryList = res.data
                for (let i = 0; i < factoryList.length; i++) {
                    let val = {}
                    val.dictLabel = factoryList[i].dictLabel
                    val.dictValue = factoryList[i].dictValue
                    factoryData.push(val)
                }
                factorySelect()
            }
        })
    })

    function initXmSelect() {
        xmSelect.render({
            el: '#selectDemo',
            checkbox: true,
            repeat: false,
            autoRow: true,
            filterable: true,
            prop: {name: 'name', value: 'diseaseId', pid: 'pid'},
            initValue: backFactory,//回显
            height: '200px',
            tips: '请选择',
            tree: {
                show: true,
                showFolderIcon: true,
                showLine: true,
                indent: 20,
                expandedKeys: [-3],
                strict: false,
            },
            data: function () {
                return selectData
            },
            on: function (data) {
                disarr = data.arr;//arr:  当前多选已选中的数据
            },
        });
    }

    function factorySelect() {
        xmSelect.render({
            el: '#selectFactory',
            checkbox: true,
            repeat: false,
            autoRow: true,
            filterable: true,
            prop: {name: 'dictLabel', value: 'dictValue'},
            initValue: backdis,//回显
            height: '200px',
            tips: '请选择',
            tree: {
                show: true,
                showFolderIcon: true,
                showLine: true,
                indent: 20,
                expandedKeys: [-3],
                strict: false,
            },
            data: function () {
                return factoryData
            },
            on: function (data) {
                factoryArr = data.arr;//arr:  当前多选已选中的数据
                debugger

                //factoryArr = data.arr
            },
        });
    }

    function submitHandler() {
        if ($.validate.form()) {
            var jsons = {};
            let formData = $('#form-drug-add').serializeArray();
            $.each(formData, function (k, v) {
                jsons[v.name] = v.value;
            });
            //疾病数组
            jsons["diseaseList"] = disarr;
            //厂家id、名称格式化拼接
            jsons["manuId"] = getManuIdOpt(factoryArr);
            jsons["manuName"] = getManuNameOpt(factoryArr);
            //其他tdk
            var drugTdk = {}
            drugTdk.newsTitle = $("input[name='newsTitle']").val();
            drugTdk.newsKeywords = $("input[name='newsKeywords']").val();
            drugTdk.newsDescription = $("input[name='newsDescription']").val();
            drugTdk.newsIllustrate = $("input[name='newsIllustrate']").val();
            drugTdk.newsContent = newsContent.getContentTxt()
            drugTdk.queTitle = $("input[name='queTitle']").val();
            drugTdk.queKeywords = $("input[name='queKeywords']").val();
            drugTdk.queDescription = $("input[name='queDescription']").val();
            drugTdk.queIllustrate = $("input[name='queIllustrate']").val();
            drugTdk.queContent = queContent.getContentTxt()
            drugTdk.priceTitle = $("input[name='priceTitle']").val();
            drugTdk.priceKeywords = $("input[name='priceKeywords']").val();
            drugTdk.priceDescription = $("input[name='priceDescription']").val();
            drugTdk.priceIllustrate = $("input[name='priceIllustrate']").val();
            drugTdk.npriceContent = priceContent.getContentTxt()
            jsons["drugTdk"] = drugTdk;
            var value = JSON.stringify(jsons)
            console.log("数据打印：", value)
            save(prefix + "/add", value);
        }
    }

    //格式化厂家id 拼接成“,”分割的字符串
    function getManuIdOpt(arr) {
        var str = "";
        arr.forEach(item => {
            str += item.dictValue + ",";
        });
        //去掉最后一个逗号(如果不需要去掉，就不用写)
        if (str.length > 0) {
            str = str.substring(0, str.length - 1);
        }
        return str;
    }

    //格式化厂家名称 拼接成“,”分割的字符串
    function getManuNameOpt(arr) {
        debugger;
        var str = "";
        arr.forEach(item => {
            str += item.dictLabel + ",";
        });
        //去掉最后一个逗号(如果不需要去掉，就不用写)
        if (str.length > 0) {
            str = str.substring(0, str.length - 1);
        }
        return str;
    }


    function save(url, data, callback) {
        var config = {
            url: url,
            type: "post",
            dataType: "json",
            data: data,
            headers: {
                'Content-Type': 'application/json;charset=utf8'
            },
            beforeSend: function () {
                $.modal.loading("正在处理中，请稍候...");
                $.modal.disable();
            },
            success: function (result) {
                if (typeof callback == "function") {
                    callback(result);
                }
                $.operate.successCallback(result);
            }
        };
        $.ajax(config)
    }

    // 多图上传
    $(".files-upload").fileinput({
        uploadUrl: ctx + 'common/uploads',
        allowedFileTypes: ['image'],
        maxFileCount: 5,
        autoReplace: false,
        uploadAsync: false
    }).on('filebatchuploadsuccess', function (event, data, previewId, index) {
        var rsp = data.response;
        let val = $("input[name='" + event.currentTarget.id + "']").val()
        if (val) {
            val += ','
        }
        console.log(event.currentTarget, event.currentTarget);
        $("input[name='" + event.currentTarget.id + "']").val(val + rsp.fileNames)
    }).on('fileremoved', function (event, id, index) {
        $("input[name='" + event.currentTarget.id + "']").val('')
    })


    //富文本
    UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
    UE.Editor.prototype.getActionUrl = function (action) {
        if (action == 'uploadimage' || action == 'uploadscrawl') {
            return '/common/upload';
        } else {
            return this._bkGetActionUrl.call(this, action);
        }
    }
    var ue = UE.getEditor('editionPrice', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })
    var ue = UE.getEditor('usageanddosage', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })
    var ue = UE.getEditor('untoward', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })

    var ue = UE.getEditor('announcements', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })
    var ue = UE.getEditor('adaptationdisease', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })

    var ue = UE.getEditor('adaptationdisease1', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })

    var ue = UE.getEditor('intendedPopulation', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })

    var ue = UE.getEditor('xingzhuang', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })

    var ue = UE.getEditor('usageanddosage1', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })

    var ue = UE.getEditor('tdkDescribe', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })

    var ue = UE.getEditor('untoward1', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })

    var ue = UE.getEditor('announcements1', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })

    var ue = UE.getEditor('suitableforthecroud1', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })


    var ue = UE.getEditor('taboos1', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })

    var ue = UE.getEditor('mutual', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })
    var ue = UE.getEditor('therapeuticEffect', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })

    var ue = UE.getEditor('mutual1', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    ue.ready(function () {
    })

    var newsContent = UE.getEditor('newsContent', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    newsContent.ready(function () {
    })

    var queContent = UE.getEditor('queContent', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    queContent.ready(function () {
    })

    var priceContent = UE.getEditor('priceContent', {
        autoHeightEnabled: false,//是否自动长高
        autoFloatEnabled: true,//是否保持toolbar的位置不动
        scaleEnabled: true,//是否可以拉伸长高
        initialFrameWidth: 'auto',//初始化编辑器宽度
        initialFrameHeight: 300,//初始化编辑器高度
    });
    priceContent.ready(function () {
    })


    $(".file-upload").fileinput({
        uploadUrl: ctx + 'common/upload',
        maxFileCount: 1,
        autoReplace: true
    }).on('fileuploaded', function (event, data, previewId, index) {
        $("input[name='" + event.currentTarget.id + "']").val(data.response.fileName)
    }).on('fileremoved', function (event, id, index) {
        $("input[name='" + event.currentTarget.id + "']").val('')
    })

    // 去除疾病error提示
    function changeError() {
        let errorValue = $('#cid').val()
        if (errorValue != "") {
            $("#cid-error").removeClass("error").addClass("remove-error")
        } else {
            return
        }

    }
</script>
</body>
</html>